package Manager;

import Entity.LoanType;
import java.util.ArrayList;

/**
 *
 * @author CONG
 */
public class LoanTypeManager {

    private ArrayList<LoanType> listLoanType;

    public LoanTypeManager() {
        listLoanType = new ArrayList<LoanType>();
    }

    public void getLoanTypeList(ArrayList<LoanType> lt) {
        listLoanType.addAll(lt);
    }

    public int getSize() {
        return listLoanType.size();
    }

    public LoanType getLoanType(int index) {
        return listLoanType.get(index);
    }
    public boolean addLoanType(LoanType lt){
        for (int i = 0; i < listLoanType.size(); i++) {
            if(listLoanType.get(i).getLoanTypeCode()==lt.getLoanTypeCode()){
                return false;
            }
        }
        listLoanType.add(lt);
        return true;
    }
    public boolean updateLoanType(LoanType lt){
        for (int i = 0; i < listLoanType.size(); i++) {
           if(listLoanType.get(i).getLoanTypeCode()==lt.getLoanTypeCode()){
               listLoanType.set(i, lt);
               return true;
           }
        }
        return false;
    }
    public boolean deleteLoanType(LoanType lt){
        for (int i = 0; i < listLoanType.size(); i++) {
            if(listLoanType.get(i).getLoanTypeCode()==lt.getLoanTypeCode()){
                listLoanType.remove(i);
                return true;
            }
        }
        return false;
    }
}
